﻿CREATE TABLE [dbo].[PersonByggnad] (
    [Id]        UNIQUEIDENTIFIER NOT NULL,
    [ValId]     UNIQUEIDENTIFIER NOT NULL,
    [Skapad]    DATETIME         NOT NULL,
    [SkapadAv]  NVARCHAR (50)    NOT NULL,
    [Andrad]    DATETIME         NULL,
    [AndradAv]  NVARCHAR (50)    NULL,
    [PersonId]  UNIQUEIDENTIFIER NOT NULL,
    [ByggnadId] UNIQUEIDENTIFIER NOT NULL,
    CONSTRAINT [PK_PersonByggnad] PRIMARY KEY CLUSTERED ([Id] ASC, [ValId] ASC),
    CONSTRAINT [FK_PersonByggnad_Byggnad] FOREIGN KEY ([ByggnadId], [ValId]) REFERENCES [dbo].[Byggnad] ([Id], [ValId]),
    CONSTRAINT [FK_PersonByggnad_Person] FOREIGN KEY ([PersonId], [ValId]) REFERENCES [dbo].[Person] ([Id], [ValId])
);

